package com.itxiuyixiu.homework.utils.GetUserUtils;


import com.itxiuyixiu.homework.utils.ReturnUtils.ReturnMessage;
import com.itxiuyixiu.homework.utils.ReturnUtils.ReturnVo;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author 黄磊
 * @date 2020/1/26
 */
@ControllerAdvice
public class GetUserExceptionAdvice {
    /**
     * 拦截捕捉自定义异常 MyException.class
     *
     * @param
     * @return
     */
    @ResponseBody
    @ExceptionHandler(value = UserNotFoundException.class)
    public ReturnVo userErrorHandler(UserNotFoundException ex) {
        return ReturnMessage.getFailureReturn(ex.getMessage());
    }
}
